﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class member_instructions : System.Web.UI.Page
{
	public string EnterpriseName = "";
    public string UserID = "";
    public string UserPower = "";
    public string Footer = "";
	
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Init.islogin(ref UserID,ref EnterpriseName,ref UserPower))
        {
            Response.Redirect("/Login.aspx");
        }
        if (!UserPower.Contains("Manager"))
        {
            Response.Write("你没有权限！");
            Response.End();
        }
        this.EnableViewState = false;
        Response.Write(Init.InitDefault());
        DataToGrid();
    }
    Common Init = new Common();
    MsSqlHelper mssql = new MsSqlHelper();
    //分页
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        try{
            
            GridView1.PageIndex = (e.NewPageIndex > -1) ? e.NewPageIndex :
            GridView1.PageIndex = 0;
        }catch(Exception ex)
        {
            Literal1.Text = "[" + e.NewPageIndex + "]" + ex.ToString();
        }
    }

    private void DataToGrid()
    {
        string sql = "select rtrim(imageid) as imageid,rtrim(url) as url from [ImageDoc](nolock) where type_id='pj' and isnull(detailid,'')='' order by imageid ";
        if (Init.IsDebug)
        {
            ResultDeBug.Text = sql;
        }
        DataSet ds = mssql.ExecuteDs(sql);
        int FileCount = ds.Tables[0].Rows.Count;
        LiteralCount.Text = FileCount.ToString();
        GridView1.DataSource = ds;
        GridView1.DataKeyNames = new string[] { "imageid" };//主键       
        GridView1.DataBind();
        if (FileCount != 0)
        {
            BaseCon.Text = BaseControl(ds.Tables[0].Rows[GridView1.PageIndex][0].ToString());
        }
        else
        {
            BaseCon.Text = "<div class=\"nulllist\">暂无需要匹配的报告</div>";
        }
    }

    private string BaseControl(string id)
    {
        string retsult="";
        retsult="<tr class=\"searli\">\r"
		    +"<td>"+id+"</td>\r"
		    +"		    <td><input id=\"drug_name\" value=\"\" placeholder=\"请输入药品名称/拼音码/编号\" /></td>\r"
            + "<td><input id=\"drug_changjia\" value=\"\" placeholder=\"请输入生产厂家\" /></td>\r"
		    +"<td class=\"QiyeC\">\r"
			+"    <a class=\"matching\" href=\"javascript:;\" data-id=\""+id+"\">匹配</a>\r"
			+"    <a class=\"delete\" href=\"javascript:;\" data-id=\""+id+"\">删除</a>\r"
		    +"</td>\r"
		    +"</tr>\r";
        return retsult;
    }
}